home *** CD-ROM | disk | FTP | other *** search
/ Video Toaster 4.3 / Video Toaster v4.3.iso / 4.2 / arexx / editor / fixproject.rexx < prev    next >
OS/2 REXX Batch file  |  1998-04-16  |  5KB  |  208 lines

  1. /* FixProject.rexx V4.0 -- Fixes a project... And it works! Honest!!!     */
  2. /* By Bob Caron (Grue) ©1995 NewTek Inc.                                  */
  3. /* (This program was Re-Created at the last minute..)                     */
  4.  
  5. call remlib('ToasterARexx.port')
  6. call remlib(PROJECT_REXX_PORT)
  7.  
  8. call addlib('PROJECT_REXX_PORT',0)
  9. call addlib('ToasterARexx.port',0)
  10.  
  11. call set_view(2)
  12.  
  13. call req_error("Fix Project V4.0     ---    Automate replacing missing croutons.")
  14.  
  15. project_end=croutonsinproject()
  16.  
  17. badcroutons=0;paths=0
  18. current_spot=0;found=0
  19. done=0 ; smart=0;buttons='00'
  20.  
  21.   do while done=0
  22.  
  23.     buttons=req_buttons("Choose Level:",buttons,"Standard","Semi-Automatic")
  24.  
  25.     if buttons="CANCEL" then return CANCEL
  26.  
  27.     if substr(buttons,1,1)="1" then do
  28.        done=1
  29.        end
  30.     if substr(buttons,2,1)="1" then do
  31.        smart=1; done=1
  32.        end
  33.   end
  34.  
  35. do count=0 to project_end-1
  36.   if crnumtype(count)="ERR!" then do
  37.      badcroutons=badcroutons+1
  38.      missing.badcroutons=crnumgettag(count,OriginalLocation)
  39.      location.badcroutons=count
  40.      end
  41. end
  42.  
  43. if smart=0 then call FixCroutonsDumb()
  44. if smart=1 then call FixCroutonsSmart()
  45.  
  46. call writetags()
  47.  
  48. if found=0 then call req_error("All Done... No 'missing' croutons found.")
  49. else call req_error("All Done... Save fixed project under a new name.")
  50.  
  51. drive="toaster:projects/"
  52. file="FixedProject"
  53. num=1
  54. do while exists(drive||file||num||".Prj")
  55.    num=num+1
  56.    end
  57. projname=file||num||".Prj"
  58.  
  59. if found>0 then do
  60.    rx startfilereq("Save Project Where?",drive,projname)
  61.    exit=1
  62.    do while exit=1
  63.      file=queryfilereq()
  64.      if file=0 then call quit
  65.      if file~="" then exit=0
  66.      address command "c:wait 1"
  67.    end
  68.  
  69.    doit=1
  70.    if exists(file) then
  71.       if req_tell("Replace existing project?")=0 then doit=0
  72.  
  73.    if doit=1 then do
  74.       call PROJECTSAVE(file)
  75.       call req_error("Saved...")
  76.    end
  77. end
  78.  
  79. call remlib("PROJECT_REXX_PORT")
  80. call remlib('ToasterARexx.port')
  81. exit
  82.  
  83.  
  84. /* Sub Routines. */
  85.  
  86. fixCroutonsDumb:
  87.  
  88. do count=1 to badcroutons
  89.   if ~exists(missing.count) then do
  90.      status=fixcrouton(count)
  91.      if status=0 then count=count-1
  92.   end
  93.  
  94. end
  95.  
  96. return
  97.  
  98. exit
  99.  
  100. fixCroutonsSmart:
  101.  
  102. do count=1 to badcroutons
  103.   if ~exists(missing.count) then do
  104.      call choppath(missing.count)
  105.      status=0
  106.      do pcount=1 to paths
  107.        path=spaths.pcount
  108.        if right(path,1)=":" then name=path||filenam
  109.        else name=path||"/"||filenam
  110.        if exists(name) then do
  111.           call req_error("Auto-Replacing Crouton:"||name)
  112.           missing.count=name
  113.           found=found+1
  114.           status=1
  115.           end
  116.        end
  117.      if status=0 then
  118.         status=fixcrouton(count)
  119.      if status=0 then count=count-1
  120.   end
  121. end
  122.  
  123. return
  124.  
  125. fixcrouton:
  126. parse arg current
  127.  
  128.  call choppath(missing.current)
  129.  call req_error("Please locate:"||missing.current)
  130.  call startfilereq("Locate Crouton ["||missing.current||"]",path,filenam)
  131.  exit=1
  132.  do while exit=1
  133.      file=queryfilereq()
  134.      if file=0 then do
  135.          if req_tell("Do you want to quit?")=1 then call quit
  136.          return 0
  137.          end
  138.      if file~="" then exit=0
  139.      address command "c:wait 1"
  140.  end
  141.  
  142.  call choppath(file)
  143.  
  144.  call pragma("D",path)
  145.  path=pragma("D","RAM:")
  146.  
  147.  if right(path,1)=":" then name=path||filenam
  148.  else name=path||"/"||filenam
  149.  
  150.  if exists(name) then do
  151.     temp=missing.current
  152.     missing.current=name
  153.     do count2=current to badcroutons
  154.        if missing.count2=temp then do
  155.           missing.count2=missing.current
  156.           call req_error("Auto-Replacing Crouton:"||missing.current)
  157.           end
  158.        end
  159.     found=found+1
  160.     dont=0
  161.     if smart=1 then do
  162.        if paths=0 then do
  163.           spaths.1=path
  164.           paths=1
  165.           return 1
  166.           end
  167.        do pcount=1 to paths
  168.          if spaths.pcount=path then
  169.             dont=1
  170.          end
  171.        if dont=0 then do
  172.          paths=paths+1
  173.          spaths.paths=path
  174.          end
  175.        end
  176.     end
  177.  if ~exists(name) then
  178.     return 0
  179. return 1
  180.  
  181. quit:
  182. call writetags()
  183. call req_error("")
  184. call remlib("PROJECT_REXX_PORT")
  185. call remlib('ToasterARexx.port')
  186. exit
  187.  
  188. choppath:
  189. parse arg file
  190.  
  191. if lastpos('/',file,length(file)-1)~=0 then do
  192.    filenam=right(file,(length(file)-lastpos('/',file,length(file)-1)))
  193.    path=left(file,(lastpos('/',file,length(file))-1))
  194.    end
  195. else do
  196.    filenam=right(file,(length(file)-lastpos(':',file,length(file)-1)))
  197.    path=left(file,(lastpos(':',file,length(file))))
  198.    end
  199.  
  200. return
  201.  
  202. writetags:
  203.  
  204. do count=1 to badcroutons
  205.    call CRNUMSETTAG(location.count,'OriginalLocation',missing.count)
  206. end
  207.  
  208. return